package com.gaoyang.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gaoyang.domain.LocalResponse;
import com.gaoyang.domain.Product1;
import com.gaoyang.domain.Product3;
import com.gaoyang.domain.ZhaoshangUser;
import com.gaoyang.service.ParamService;
import com.gaoyang.service.ProductService;
import com.gaoyang.thread.BankThread;
import com.gaoyang.thread.SimpleRunner;
import com.gaoyang.thread.SimpleRunner4Qiang;
import com.gaoyang.util.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

@Controller
@RequestMapping("/product")
public class ProductController {

    private static Logger logger = LogManager.getLogger(ProductController.class);

    @Autowired
    ProductService productService;

    @Autowired
    ParamService paramService;

    public volatile static boolean switchActivity = false;

    @RequestMapping(value = "/stop")
    public void stop() {
        switchActivity = false;
    }

    @RequestMapping(value = "/page")
    public ModelAndView toPage (HttpSession httpSession) {
        ModelAndView model = new ModelAndView();
        //用户信息列表
        List<ZhaoshangUser> userList = productService.getUserList();
        model.addObject("userList", userList);

        String userId = userList.get(0).getUserId();
        System.out.println("-------------获取用户列表成功--------------------");

        //下午三点产品列表
        List<Product1> product1List = this.get3HourList(userId);
        model.addObject("product1List", product1List);

        Map<String, Product1> product1Map = new HashMap();
        for(Product1 product1 : product1List) {
            product1Map.put(product1.getProductNo(), product1);
        }

        httpSession.setAttribute("product1Map", product1Map);
        System.out.println("-------------获取下午三点列表成功--------------------");

        //周三五折产品列表
        List<Product1> product2List = this.getWednesdayList(userId);
        model.addObject("product2List", product2List);

        Map<String, Product1> product2Map = new HashMap<String, Product1>();
        for(Product1 product2 : product2List) {
            product2Map.put(product2.getProductNo(), product2);
        }

        httpSession.setAttribute("product2Map", product2Map);
        System.out.println("-------------获取周三五折列表成功--------------------");

        //周三五折产品列表
        List<Product3> product3List = this.get4QiangList(userId);
        model.addObject("product3List", product3List);

        Map<String, Product3> product3Map = new HashMap<String, Product3>();
        for(Product3 product3 : product3List) {
            product3Map.put(product3.getGoodsId(), product3);
        }

        httpSession.setAttribute("product3Map", product3Map);
        System.out.println("-------------获取抢列表成功--------------------");

        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String timeStr = dtf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(Long.valueOf(getServerTime())), ZoneId.systemDefault()));
        LocalDateTime server = LocalDateTime.parse(timeStr, dtf);
        model.addObject("hour", server.getHour());
        model.addObject("minute", server.getMinute());
        model.addObject("second", server.getSecond());

        model.setViewName("index");
        return model;
    }

    public List<Product1> get3HourList(String userId) {
        List<Product1> productList = new ArrayList();
        String productUrl = API_URL.ZSYH_ADDRESS2 + API_URL.ZSYH.PRODUCT_9POINT_LIST_URL2;
        Map params = new HashMap();

        params.put("body", "{districtId='', labelId='04', cityNo='" + API_URL.CITY + "', longitude='116.456551', parmName='WEDNESDAY', signOfOrder='0', regionId='', dimension='39.931397', merTypeId2=''}");
        params.put("syshead", "{chnlUserId='" + userId + "', trans_code='SI_PRD0020', sessionId='null', chnlId='01', pageIndex=1, pageSize=10}");
        params.put("p0", "a");
        params.put("p1", "50");
        params.put("p2", "meizu");
        params.put("p3", "c799040f6dea4b8dbcffb74eaf680e0cc");
        params.put("p4", "afea3edbc21f41cfbf957b186361a517");
        params.put("p5", userId);
        params.put("p6", "507867717");
        params.put("p7", "e92827f6fa9e4c78ae5f8e35407a9e72");
        params.put("p8", "eda1b84e588c48e270d276affa");
        params.put("p9", "null");
        params.put("p10", "c589b6c9e0d432181688e5a705da728");
        String result = HttpUtils4Black.postUrl4ZSYH(productUrl, params);
        JSONObject obj = JSONObject.parseObject(result);
        JSONObject bodyObj = (JSONObject) obj.get("body");
        //获取一共几页
        int totalPage = (Integer.parseInt(bodyObj.getString("totalRecords")) / 10) + 1 ;

        for (int i = 0; i < totalPage; i++) {
            Map params1 = new HashMap();
            params1.put("body", "{districtId='', labelId='04', cityNo='" + API_URL.CITY + "', longitude='116.456551', parmName='WEDNESDAY', signOfOrder='0', regionId='', dimension='39.931397', merTypeId2=''}");
            params1.put("syshead", "{chnlUserId='" + userId + "', trans_code='SI_PRD0020', sessionId='null', chnlId='01', pageIndex=" + (i + 1) + ", pageSize=10}");
            params1.put("p0", "a");
            params1.put("p1", "50");
            params1.put("p2", "meizu");
            params1.put("p3", "c799040f6dea4b8dbcffb74eaf680e0cc");
            params1.put("p4", "afea3edbc21f41cfbf957b186361a517");
            params1.put("p5", userId);
            params1.put("p6", "507867717");
            params1.put("p7", "e92827f6fa9e4c78ae5f8e35407a9e72");
            params1.put("p8", "eda1b84e588c48e270d276affa");
            params1.put("p9", "null");
            params1.put("p10", "c589b6c9e0d432181688e5a705da728");
            String pageResult = HttpUtils4Black.postUrl4ZSYH(productUrl, params1);
            JSONObject obj2 = JSONObject.parseObject(pageResult);
            JSONObject bodyObj2 = (JSONObject) obj2.get("body");
            JSONArray rows = bodyObj2.getJSONArray("rows");
            if (rows != null) {
                for (int j = 0; j < rows.size(); j++) {
                    JSONObject obj3 = rows.getJSONObject(j);
                    Product1 product = new Product1();
                    product.setProductName(obj3.getString("productName"));
                    product.setProductPicUrl(obj3.getString("productPicUrl"));
                    product.setProductNo(obj3.getString("productNo"));
                    product.setBakNo(obj3.getString("bakNo"));
                    product.setValidityPerBegin(obj3.getString("validityPerBegin"));
                    product.setValidityPerEnd(obj3.getString("validityPerEnd"));
                    product.setBtnStatus(obj3.getString("btnStatus"));
                    product.setBtnText(obj3.getString("btnText"));
                    product.setIsRemained("0");
                    productList.add(product);
                }
            }
        }
        return productList;
    }

    public List<Product1> getWednesdayList(String userId) {
        List<Product1> productList = new ArrayList();
        String productUrl = API_URL.ZSYH_ADDRESS2 + API_URL.ZSYH.PRODUCT_9POINT_LIST_URL2;
        Map params = new HashMap();
        params.put("body", "{districtId='', labelId='03', cityNo='" + API_URL.CITY + "', longitude='116.456551', parmName='WEDNESDAY', signOfOrder='0', regionId='', dimension='39.931397', merTypeId2=''}");
        params.put("syshead", "{chnlUserId='" + userId + "', trans_code='SI_PRD0020', sessionId='null', chnlId='01', pageIndex=1, pageSize=10}");
        params.put("p0", "a");
        params.put("p1", "50");
        params.put("p2", "meizu");
        params.put("p3", "c799040f6dea4b8dbcffb74eaf680e0cc");
        params.put("p4", "afea3edbc21f41cfbf957b186361a517");
        params.put("p5", userId);
        params.put("p6", "507867717");
        params.put("p7", "e92827f6fa9e4c78ae5f8e35407a9e72");
        params.put("p8", "eda1b84e588c48e270d276affa");
        params.put("p9", "null");
        params.put("p10", "c589b6c9e0d432181688e5a705da728");
        String result = HttpUtils4Black.postUrl4ZSYH(productUrl, params);
        JSONObject obj = JSONObject.parseObject(result);
        JSONObject bodyObj = (JSONObject) obj.get("body");
        //获取一共几页
        int totalPage = (Integer.parseInt(bodyObj.getString("totalRecords")) / 10) + 1 ;

        for (int i = 0; i < totalPage; i++) {
            Map params1 = new HashMap();
            params1.put("body", "{districtId='', labelId='03', cityNo='" + API_URL.CITY + "', longitude='116.456551', parmName='WEDNESDAY', signOfOrder='0', regionId='', dimension='39.931397', merTypeId2=''}");
            params1.put("syshead", "{chnlUserId='" + userId + "', trans_code='SI_PRD0020', sessionId='null', chnlId='01', pageIndex=" + (i + 1) + ", pageSize=10}");
            params1.put("p0", "a");
            params1.put("p1", "50");
            params1.put("p2", "meizu");
            params1.put("p3", "c799040f6dea4b8dbcffb74eaf680e0cc");
            params1.put("p4", "afea3edbc21f41cfbf957b186361a517");
            params1.put("p5", userId);
            params1.put("p6", "507867717");
            params1.put("p7", "e92827f6fa9e4c78ae5f8e35407a9e72");
            params1.put("p8", "eda1b84e588c48e270d276affa");
            params1.put("p9", "null");
            params1.put("p10", "c589b6c9e0d432181688e5a705da728");
            String pageResult = HttpUtils4Black.postUrl4ZSYH(productUrl, params1);
            JSONObject obj2 = JSONObject.parseObject(pageResult);
            JSONObject bodyObj2 = (JSONObject) obj2.get("body");
            JSONArray rows = bodyObj2.getJSONArray("rows");
            if (rows != null) {
                for (int j = 0; j < rows.size(); j++) {
                    JSONObject obj3 = rows.getJSONObject(j);
                    Product1 product = new Product1();
                    product.setProductName(obj3.getString("productName"));
                    product.setProductPicUrl(obj3.getString("productPicUrl"));
                    product.setProductNo(obj3.getString("productNo"));
                    product.setBakNo(obj3.getString("bakNo"));
                    product.setValidityPerBegin(obj3.getString("validityPerBegin"));
                    product.setValidityPerEnd(obj3.getString("validityPerEnd"));
                    product.setBtnStatus(obj3.getString("btnStatus"));
                    product.setBtnText(obj3.getString("btnText"));
                    product.setIsRemained("0");
                    productList.add(product);
                }
            }
        }
        return productList;
    }

    public List<Product3> get4QiangList(String userId) {
        List<Product3> productList = new ArrayList();
        String productUrl = API_URL.ZSYH_ADDRESS3 + "Campaign/getPanicBuyCampaignList.json";
        Map params = new HashMap();

        //11点
//        params.put("cGName", "SXLP201811");
        //14点
//        params.put("cGName", "9FZPHQD73");
        String gname = paramService.getParamMap().get("gname");
        params.put("cGName", gname);
        params.put("pageIndex", "1");
        params.put("pageSize", "999");
        params.put("cityId", "10");
        params.put("campaignNo", "");
        params.put("groupFlag", "2162688");

        params.put("p0", "a");
        params.put("p1", "76");
        params.put("p2", "baidu");
        params.put("p3", "9cb20f99b7c540ec8a85c599833e16d0c");
        params.put("p4", "88cd080cfc154d938d35e04fdc5b5d5e");
        params.put("p5", userId);
        params.put("p6", "558836213");
        params.put("p7", "dd18846c8ebb4b10ba324fb3aa1609d5");
        params.put("p8", "faa3f523959f47ae86edfc200b75d46e");
        params.put("p9", "3028dd196cbe4acab3246322b4b6500c");
        params.put("p10", "ebd41ce9ed1541d4af73737798b132d3");
        String result = HttpUtils4Black.postUrl4ZSYH(productUrl, params);
        JSONObject obj = JSONObject.parseObject(result);
        JSONArray campaigns = (JSONArray) obj.get("campaigns");
        JSONObject campaign = campaigns.getJSONObject(0);
        String campaignNo = campaign.getString("campaignNo");
        String cGName = obj.getString("cGName");
        JSONArray products = campaign.getJSONArray("products");
        for (Object product : products) {
            JSONObject productObject = (JSONObject)product;
            String goodsId = productObject.getString("goodsId");
            String productName = productObject.getString("productName");
            Product3 product3 = new Product3();
            product3.setTitle(productName);
            product3.setCampaignNo(campaignNo);
            product3.setcGName(cGName);
            product3.setGoodsId(goodsId);
            productList.add(product3);
        }
        return productList;
    }

    @RequestMapping(value = "/submit3hour", method = RequestMethod.POST)
    @ResponseBody
    public LocalResponse submit3hour(HttpServletRequest request, HttpSession httpSession) {
        LocalResponse response = new LocalResponse();
        switchActivity = true;
        String userStr1 = request.getParameter("userStr1");
        String product1Str = request.getParameter("product1Box");
        if (StringUtils.isBlank(userStr1) || StringUtils.isBlank(product1Str)) {
            logger.info("选项不能为空");
            return response;
        }
        if (!checkBeginTime(14)) {
            logger.info("时间尚未开始");
            return response;
        }
        String[] user1Array = userStr1.split(",");
        String[] product1Array = product1Str.split(",");

        Map<String, String> initParams = paramService.getParamMap();
        Map<String, Product1> product1Map = (Map<String, Product1>)httpSession.getAttribute("product1Map");
        ExecutorService pool = Executors.newFixedThreadPool(30);
        for (int i = 0; i < user1Array.length; i++) {
            if (StringUtils.isNotBlank(user1Array[i])) {
                ZhaoshangUser userBean = productService.findUserByUserId(user1Array[i]);
                for (int j = 0; j < product1Array.length; j++) {
                    Map<String, String> params = new HashMap();
                    Product1 productBean = product1Map.get(product1Array[j]);
                    params.put("body", "{payType='1000', bakNo='" + productBean.getBakNo() + "', isCanRush='0', moduleType='1', mobilePhone='', productNo='" + productBean.getProductNo() + "', accountNum=1}");
                    params.put("syshead", "{chnlUserId='" + userBean.getUserId() + "', chnlId='01', trans_code='SI_ORD0016', sessionId='" + params.get("p9") + "'}");
                    params.put("p0", initParams.get("p0"));
                    params.put("p1", initParams.get("p1"));
                    params.put("p2", initParams.get("p2"));
                    params.put("p3", initParams.get("p3"));
                    params.put("p4", initParams.get("p4"));
                    params.put("p5", userBean.getUserId());
                    params.put("p6", initParams.get("p6"));
                    params.put("p7", initParams.get("p7"));
                    params.put("p8", initParams.get("p8"));
                    params.put("p9", initParams.get("p9"));
                    params.put("p10", initParams.get("p10"));
                    Map<String, String> logMap = new HashMap();
                    logMap.put("userName", userBean.getUserName());
                    logMap.put("productName", productBean.getProductName());
                    try {
//                        Callable callable = new BankThread(Integer.parseInt(initParams.get("times")), params, logMap);
//                        Future future = pool.submit(callable);
//                        output.append(future.get() + "</br>");
//                        response.setData(output.toString());
//                        System.out.println(">>" + future.get());

                        SimpleRunner runner = new SimpleRunner();
                        runner.setRunIndex(userBean.getUserName(), productBean.getProductName(), params);
                        pool.submit(runner);

                    } catch (Exception e) {
                        e.printStackTrace();
                    }
//					new Thread(new BankThread(Integer.parseInt(initParams.get("times")), params, logMap)).start();
                }
            }
        }
        return response;
    }

    @RequestMapping(value = "/submitWednesDay", method = RequestMethod.POST)
    @ResponseBody
    public LocalResponse submitWednesDay (HttpServletRequest request, HttpSession httpSession) {
        LocalResponse response = new LocalResponse();
        switchActivity = true;
        String userStr2 = request.getParameter("userStr2");
        String product2Str = request.getParameter("product2Box");
        if (StringUtils.isBlank(userStr2) || StringUtils.isBlank(product2Str)) {
            logger.info("选项不能为空");
            return response;
        }
        if (!checkBeginTime(10)) {
            logger.info("时间尚未开始");
            return response;
        }
        String[] user2Array = userStr2.split(",");
        String[] product2Array = product2Str.split(",");
        Map<String, String> initParams = paramService.getParamMap();
        Map<String, Product1> product1Map = (Map<String, Product1>)httpSession.getAttribute("product2Map");
        ExecutorService pool = Executors.newFixedThreadPool(10);
        for (int i = 0; i < user2Array.length; i++) {
            if (StringUtils.isNotBlank(user2Array[i])) {
                ZhaoshangUser userBean = productService.findUserByUserId(user2Array[i]);
                for (int j = 0; j < product2Array.length; j++) {
                    Map<String, String> params = new HashMap();
                    Product1 productBean = product1Map.get(product2Array[j]);
                    params.put("body", "{payType='1000', bakNo='" + productBean.getBakNo() + "', isCanRush='0', moduleType='1', mobilePhone='', productNo='" + productBean.getProductNo() + "', accountNum=1}");
                    params.put("syshead", "{chnlUserId='" + userBean.getUserId() + "', chnlId='01', trans_code='SI_ORD0016', sessionId='" + params.get("p9") + "'}");
                    params.put("p0", initParams.get("p0"));
                    params.put("p1", initParams.get("p1"));
                    params.put("p2", initParams.get("p2"));
                    params.put("p3", initParams.get("p3"));
                    params.put("p4", initParams.get("p4"));
                    params.put("p5", userBean.getUserId());
                    params.put("p6", initParams.get("p6"));
                    params.put("p7", initParams.get("p7"));
                    params.put("p8", initParams.get("p8"));
                    params.put("p9", initParams.get("p9"));
                    params.put("p10", initParams.get("p10"));
                    Map<String, String> logMap = new HashMap();
                    logMap.put("userName", userBean.getUserName());
                    logMap.put("productName", productBean.getProductName());

                    try {
                        SimpleRunner runner = new SimpleRunner();
                        runner.setRunIndex(userBean.getUserName(), productBean.getProductName(), params);
                        pool.submit(runner);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }

        return response;
    }

    @RequestMapping(value = "/submitQiang", method = RequestMethod.POST)
    @ResponseBody
    public LocalResponse submitQiang (HttpServletRequest request, HttpSession httpSession) {
        LocalResponse response = new LocalResponse();
        String userStr3 = request.getParameter("userStr3");
        String product3Str = request.getParameter("product3Box");
        if (StringUtils.isBlank(userStr3) || StringUtils.isBlank(product3Str)) {
            logger.info("选项不能为空");
            return response;
        }
        int beginTime = Integer.valueOf(paramService.getParamMap().get("beginTime"));
        if (!checkBeginTime(beginTime)) {
            logger.info("时间尚未开始");
            return response;
        }
        String[] user3Array = userStr3.split(",");
        String[] product3Array = product3Str.split(",");
        Map<String, String> initParams = paramService.getParamMap();
        Map<String, Product3> product3Map = (Map<String, Product3>)httpSession.getAttribute("product3Map");
        ExecutorService pool = Executors.newFixedThreadPool(10);
        for (int i = 0; i < user3Array.length; i++) {
            if (StringUtils.isNotBlank(user3Array[i])) {
                ZhaoshangUser userBean = productService.findUserByUserId(user3Array[i]);
                for (int j = 0; j < product3Array.length; j++) {
                    Map<String, String> params = new HashMap();
                    Product3 productBean = product3Map.get(product3Array[j]);
                    String uuid = UUID.randomUUID().toString();
                    String goodsId = productBean.getGoodsId();
                    String campaignNo = productBean.getCampaignNo();
                    String cGName = productBean.getcGName();
                    params.put("goodsId", goodsId);
                    params.put("campaignNo", campaignNo);
                    params.put("cGName", cGName);
                    params.put("sign", getSign(cGName, campaignNo, goodsId, uuid, userBean.getUserId()));
                    params.put("r", uuid);

                    params.put("p0", initParams.get("p0"));
                    params.put("p1", initParams.get("p1"));
                    params.put("p2", initParams.get("p2"));
                    params.put("p3", initParams.get("p3"));
                    params.put("p4", initParams.get("p4"));
                    params.put("p5", userBean.getUserId());
                    params.put("p6", initParams.get("p6"));
                    params.put("p7", initParams.get("p7"));
                    params.put("p8", initParams.get("p8"));
                    params.put("p9", initParams.get("p9"));
                    params.put("p10", initParams.get("p10"));

                    try {
                        SimpleRunner4Qiang runner = new SimpleRunner4Qiang();
                        runner.setRunIndex(userBean.getUserName(), productBean.getTitle(), params);
                        pool.submit(runner);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }

        return response;
    }


    @RequestMapping(value = "/getLogs", method = RequestMethod.GET)
    @ResponseBody
    public LocalResponse getLogs(HttpServletRequest request) {
        LocalResponse response = new LocalResponse();
        StringBuffer output = new StringBuffer();
        List<String> strings = FileUtil.readLastNLine("/work/app/logs/info.log", 50L);
        strings.forEach(s -> output.append(s));
        response.setData(output);
        return response;
    }

    public static boolean checkBeginTime(int hour) {
        boolean flag = false;
//        String serverTime = getServerTime();
//        String serverTime = "1530860281000";
//        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//        String timeStr = dtf.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(Long.valueOf(serverTime)), ZoneId.systemDefault()));
//        LocalDateTime server = LocalDateTime.parse(timeStr, dtf);
        LocalDateTime server = LocalDateTime.now();
        LocalDateTime fire = LocalDateTime.now().withHour(hour).withMinute(59).withSecond(50).withNano(0);
        if (server.isEqual(fire)) flag = true;
        if (server.isBefore(fire)) flag = false;
        if (server.isAfter(fire)) flag = true;
        logger.info("服务器时间：" + server + "比较" + "触发时间：" + fire + " 结果：" + flag);
        return flag;
    }

    private static String getServerTime() {
        String productUrl = API_URL.ZSYH_ADDRESS2 + API_URL.ZSYH.PRODUCT_9POINT_LIST_URL2;
        Map params = new HashMap();

        params.put("body", "{cityNo='10', labelId='04', curVer='null', productNos='null'}");
        params.put("syshead", "{trans_code='SI_PRD0026', chnlId='01', sessionId='f5d82c2218b94591b911c0e3da0c0eb9', chnlUserId='17A8AF7157CD46FBAC97188626CA08A0'}");
        params.put("p0", "a");
        params.put("p1", "75");
        params.put("p2", "tencent");
        params.put("p3", "9cb20f99b7c540ec8a85c599833e16d0c");
        params.put("p4", "e40a4a2bd11941fea6f3d071d81fc2b5");
        params.put("p5", "17A8AF7157CD46FBAC97188626CA08A0");
        params.put("p6", "557796155");
        params.put("p7", "dd18846c8ebb4b10ba324fb3aa1609d5");
        params.put("p8", "f6006d77734a4669a73326c6cc166445");
        params.put("p9", "f5d82c2218b94591b911c0e3da0c0eb9");
        params.put("p10", "a66d2e1b203d46f0bdf36c8a81b5aa79");
        params.put("groupFlag", "2162688");
        String result = HttpUtils4Black.postUrl4ZSYH(productUrl, params);
        JSONObject obj = JSONObject.parseObject(result);
        JSONObject bodyObj = (JSONObject) obj.get("body");
        System.out.println(DateUtils.timeStamp2Date(bodyObj.getString("serverTime"), "yyyy-MM-dd HH:mm:ss"));
        return bodyObj.getString("serverTime");
    }

    public static void main(String[] args) {

        System.out.println(getServerTime());

//        if (checkBeginTime(14)) {
//            String productUrl = API_URL.ZSYH_ADDRESS3 + API_URL.ZSYH.LAGANXIANG;
//            String userId = "17A8AF7157CD46FBAC97188626CA08A0";
//            String uuid = UUID.randomUUID().toString();
//            String goodsId = "26877";
//            String campaignNo = "25c361a2-ea5e-41c4-a174-54d1cd2e041b";
//            String cGName = "SIXLP201807";
//            Map params = new HashMap();
//            params.put("goodsId", goodsId);
//            params.put("campaignNo", campaignNo);
//            params.put("cGName", cGName);
//            params.put("sign", getSign(cGName, campaignNo, goodsId, uuid, userId));
//            params.put("r", uuid);
////		params.put("r", "36feed55-f8ee-40ba-a759-ec6c9dd692ae");
//
//            params.put("p0", "a");
//            params.put("p1", "66");
//            params.put("p2", "360");
//            params.put("p3", "f7edad836006468394ac6286b2c605b82");
//            params.put("p4", "9e8918214be9463488c1722b5650faf4");
//            params.put("p5", userId);
//            params.put("p6", "532753056");
//            params.put("p7", "dfe1865084fd49d1a45fcaa9a579f940");
//            params.put("p8", "7c4ad8fa8e954b43b2f83ad3dff1a7ce");
//            params.put("p9", "f5d82c2218b94591b911c0e3da0c0eb9");
//            params.put("p10", "b0a6580ab8cc4bccba3b8a891a06588f");
//
//            String result = HttpUtils4Black.postUrl4ZSYH(productUrl, params);
//            System.out.println(result);
//        }
    }

    public static String getSign(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5)
    {
        paramString5 = MD5Tools.getMd5LowerCase("Pb5.0" + paramString5);
        paramString1 = MD5Tools.getMd5LowerCase(paramString1 + paramString2 + paramString3 + paramString4 + paramString5);
        return paramString1.toLowerCase();

    }
}
